<template>
	<view class="p30">
		<view class="bg-fff radius20 ">
			<view class="fw-w fs32 tit-ac p20">邀请您加入</view>
			<u-empty v-if="!list.length" text="暂无邀请" marginTop="100"></u-empty>
			<view class="p20 " v-for="(item,index) in list" :key="index">
				<view class="flex1">
					<masterInfo :data="item" />
				</view>
				<view class="flex row-right mt20">
					<view class="ml20">
						<u-button type="warning" plain size="mini" @click="refuseJoin(item.id)">拒绝</u-button>
					</view>
					<view class="ml20">
						<u-button type="warning" size="mini" @click="agreeJoin(item.id)">同意</u-button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				page: 1
			};
		},
		onShow() {
			this.getList()
		},
		onReachBottom() {
			this.getList('down')
		},
		methods: {
			async agreeJoin(invite_id) { //同意加入
				await this.$showModal('同意加入')
				this.$request('/master/agency/agreeJoin', {
					invite_id
				}).then(res => {
					this.$msg(res.msg)
					this.getList()
				})
			},
			async refuseJoin(invite_id) { //拒绝加入
				await this.$showModal('拒绝')
				this.$request('/master/agency/refuseJoin', {
					invite_id
				}).then(res => {
					this.$msg(res.msg)
					this.getList()
				})
			},
			getList(e) {
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					page: this.page,
				}
				this.$request('/master/agency/inviteList', params).then(res => {
					let list = res.data.data
					e == 'down' ? this.list.push(...list) : this.list = list
				})
			},
		}
	}
</script>

<style lang="scss">

</style>